package com.kyivmohyla.kma2.client.view.common;

import com.google.gwt.cell.client.NumberCell;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.HasData;
import com.kyivmohyla.kma2.shared.model.UIEquipment;

public class EquipmentCellTableWidget extends Composite {

    private final CellTable<UIEquipment> equipmentCellTable;

    public EquipmentCellTableWidget() {
        equipmentCellTable = new CellTable<UIEquipment>();
        equipmentCellTable.addColumn(new Column<UIEquipment, Number>(new NumberCell()) {
            @Override
            public Number getValue(UIEquipment object) {
                return object.getEquipmentId();
            }
        }, "ID");
        equipmentCellTable.addColumn(new Column<UIEquipment, String>(new TextCell()) {
            @Override
            public String getValue(UIEquipment object) {
                return object.getName();
            }
        }, "Name");
        equipmentCellTable.addColumn(new Column<UIEquipment, String>(new TextCell()) {
            @Override
            public String getValue(UIEquipment object) {
                return object.getDescription();
            }
        }, "Description");
        initWidget(equipmentCellTable);
    }

    public HasData getEquipmentCellTable() {
        return equipmentCellTable;
    }

    public Widget asWidget() {
        return this;
    }
}